import {ColumnsType} from "antd/es/table";
import {SecurityPath} from "type/entity/SecurityPath";
import {columnDataIndex, columnOrder, columnRemark} from "./index";
import {Space, Tag} from "antd";
import {Link} from "react-router-dom";
import {getMethodTag} from "../util/tag-util";

const pathColumns: ColumnsType<SecurityPath> = [
    columnDataIndex,
    {
        key: 'id',
        dataIndex: 'id',
        title: '路径编号',
        width: 110,
        align: "center",
    },
    // {
    //     key: 'parentId',
    //     dataIndex: 'parentId',
    //     title: '父路径',
    //     width: 110,
    //     align: "center",
    // },
    {
        key: 'pattern',
        dataIndex: 'pattern',
        title: '路径模式',
        width: 200,
        // ellipsis: {showTitle: false},
        // render: ellipsisHandler
    },
    {
        key: 'explain',
        dataIndex: 'explain',
        title: '路径说明',
        width: 200,
        // ellipsis: {showTitle: false},
        // render: ellipsisHandler
    },
    {
        key: 'method',
        dataIndex: 'method',
        title: '请求方法',
        width: 90,
        render: getMethodTag
    },
    {
        key: 'server',
        dataIndex: 'server',
        title: '服务模块',
        width: 100,
        render: value => <Tag color={"green"}>{value}</Tag>
    },
    {
        key: 'last',
        dataIndex: 'last',
        title: '菜单级别',
        width: 100,
        align: "center",
        render: value => value? <Tag color={"#334026"}>子路径</Tag> : <Tag color={"#871274"}>父路径</Tag>,
    },
    columnOrder,
    columnRemark,
    {
        key: "options",
        title: "操作",
        dataIndex: "options",
        align: "center",
        width: 150,
        fixed: "right",
        render: (_, record, __) => {
            return <Space size={15}>
                <Link key={"menu-details"} to={"details"} state={record}>详情</Link>
                <Link key={"menu-update"} to={"update"} state={record}>更新</Link>
                <Link key={"menu-delete"} style={{color: "#c13c3c"}} to={"delete"} state={record}>删除</Link>
            </Space>;
        }
    }
];

export default pathColumns;